import { Table, TableProps } from '@inbiz/antd';
import React, { forwardRef } from 'react';
import { RecordType } from '../../interfaces';
import '../../style.less';

const PrintTable = (props: TableProps<RecordType>, ref) => {
  const { columns = [], dataSource, style, size } = props;
  const newCols = columns.slice(0, columns.length - 1).map((column) => {
    return {
      ...column,
      onHeaderCell: undefined,
      sorter: undefined,
      width: undefined,
    };
  });

  return (
    <div>
      <div className={'page-break'} />
      <Table
        rowKey={'id'}
        ref={ref}
        style={style}
        pagination={false}
        columns={newCols}
        dataSource={dataSource}
        size={size}
      />
    </div>
  );
};

export default forwardRef(PrintTable);
